window.onload = function ()
{
	var oBtn=document.getElementById('totop');
	var bSys=true;
	var timer=null;
	
	window.onscroll=function ()
	{
		if(!bSys)
		{
			clearInterval(timer);
		}
		bSys=false;
	};
	
	oBtn.onclick=function ()
	{
		timer=setInterval(function (){
			var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
			var iSpeed=Math.floor(-scrollTop/8);
			
			if(scrollTop==0)
			{
				clearInterval(timer);
			}
			
			bSys=true;
			document.documentElement.scrollTop=document.body.scrollTop=scrollTop+iSpeed;
		}, 30);
	};
};

$('footlink').innerHTML +='<a><img src="http://127.0.0.1/top.png" style="position:fixed; bottom:0; right:0;width:100px;height:100px" id="totop"/></a>';